<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ include file="/WEB-INF/component/commonTagLib.jsp" %>

    
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<%@ include file="/WEB-INF/component/commonCSS.jsp" %> 

<style type="text/css">
    	div.col-sm-3.text-left,div.col-sm-5.text-left,div.col-sm-10.text-left{
    	    color:#949494;
    	}
    	label.checkLong *{
    		vertical-align: middle;
    		margin: 0px;
    	}
</style>
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    
    <section class="content-header">
        <h1 >${(tag==0)?"核实":"详情"}</h1>
         <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i><spring:message code="message.lable.first"/></a></li>
              <li><a href="#">交易</a></li>
			  <li><a href="#">缺货审核</a></li>
              <li><a href="#">基层医院</a></li>
        </ol> 
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <!-- form start -->
            <form role="form" id="form" class="form-horizontal"  method="post">
            	<input hidden name='qualityspecCode' value='<c:out value="${detail.qualityspecCode}" />' >
            	
                <div class="box-body">
	                <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right">品规编码<spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                            <c:out value="${detail.qualityspecCode}" />
	                        </div>
	                        <label class="col-sm-3 text-right"><spring:message code="message.listForm.tongYongMing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                           <c:out value="${detail.qualityspecName }" />
	                        </div>
	                 </div>
	                 <div class="line"></div>
	                  <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right"><spring:message code="message.listForm.jiXing"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                           <c:out value="${detail.formName }" />
	                        </div>
	                        <label class="col-sm-3 text-right"><spring:message code="message.listForm.guiGe"/><spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-3 text-left">
	                           <c:out value="${detail.specName }" />
	                        </div>
	                  </div>
	                   
	                    <div class="line"></div>
	                    <div class="form-group form-group-xs">
	                       <label class="col-sm-2 text-right">缺货数量<spring:message code="message.yanZheng.maoHao"/></label>
	                            <div class="col-sm-3 text-left">
	                                 <c:out value="${detail.count }" />
	                            </div>
	                   </div>
	                   <div class="line"></div>
	                      <div class="form-group form-group-xs">
                            <label class="col-sm-2 text-right">缺货时段<spring:message code="message.yanZheng.maoHao"/></label>
                            <div class="col-sm-10 text-left">
                             <c:if test="${detail.is_longterm==1}">
                              		<label class='checkLong'><input type="radio" id="longTerm" name='isLongterm'  <c:out value="${detail.is_longterm==1?'checked':''}"></c:out>  /><span> 长期</span></label>  &nbsp;
                             </c:if>
                              <c:if test="${detail.is_longterm==0}">
                               		<div id='shortTable' >
                                 	<label class='checkLong'><input type="radio" id="shortTerm" name='isLongterm'  <c:out value="${detail.is_longterm==0?'checked':''}"></c:out>  /><span> 短期</span></label>
	                                   <table style="width:180px;"  >
			                             <tr>
			                                <td style="width:80px">
			                                	<fmt:formatDate value="${detail.start_datetime}" pattern="yyyy-MM-dd"/> 
			                                </td>
			                                <td>-&nbsp;</td>
			                                <td style="width:50%">
			                               		 <fmt:formatDate value="${detail.end_datetime}" pattern="yyyy-MM-dd"/>
			                                </td>
			                              </tr>
			                           </table>
                               </div>
                                </c:if>
                            </div>
                       </div>
                      
                       <div class="line"></div>
	                   <div class="form-group form-group-xs">
	                        <label class="col-sm-2 text-right">缺货原因<spring:message code="message.yanZheng.maoHao"/></label>
	                        <div class="col-sm-9 text-left">
	                        	   <textarea rows="3"  readonly class="form-control" ><c:out value="${detail.shortage_reason}"/></textarea> 
	                        </div>
	                   </div>
			                   <div class="line"></div>
			                   <div class="form-group form-group-xs">
			                        <label class="col-sm-2 text-right">审核备注<spring:message code="message.yanZheng.maoHao"/></label>
			                        <div class="col-sm-9 text-left">
			                        	   <textarea rows="3" ${tag==0?"":"readonly"}  class="form-control" name="bur_audit_remark" id="bur_audit_remark" maxlength="2000" ><c:out value="${detail.bur_audit_remark}"></c:out></textarea> 
			                        </div>
			                   </div>
                </div>
               <div class="box-footer text-center">
               		<c:if test="${tag==0}">
	               		<label onclick="submitAudit(1)" class="btn btn-success btn-sm">核实缺货</label>
	               		<label onclick="submitAudit(2)" class="btn btn-success btn-sm">核实未缺货</label>
               		</c:if>
                    <a href="javascript:history.go(-1)" class="btn btn-danger btn-sm"><spring:message code="message.button.getBackSpacing"/></a>
                </div>
            </form>
        </div>
    </section>
</body>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">
	$(function(){
		$("input[name='isLongterm']").on('change',function(e){
			var tag = $(this).val();
			if(tag==0){
				$('#shortTable').show();
			}else{
				$('#shortTable').hide();
			}
		});
	})
		function submitAudit(_tag){
			if(!valid()){
				return;
			}
	 		$.HN.message.confirm('确定提交吗？', '', '').on(function (e) {
    			if (e) {
    				var shortageId ="${detail.shortage_id}"
    				var bur_audit_remark =$('#bur_audit_remark').val();
    				var auditStatus = _tag;
    				var postData ={
    						shortageId:shortageId,
    						burAuditRemark:bur_audit_remark,
    						burAuditStatus:auditStatus
    				};
    	    		$.post("${ctx}/baseShortage/declareShortageByWSJ.html",postData, function(result) {
    	    			if (result.success) {
    	    				top.$.HN.message.alert("操作成功！", "消息", "success");
    	    				setTimeout(location.href='${ctx}/baseShortage/toAuditListByWSJ.html', 1500 );
    	    			} else {
    	    				top.$.HN.message.alert("操作失败！", "消息", "error");
    	    			}
    	    		}, "json")
    			}
    		}); 
		}
	
	function valid(){
		var bur_audit_remark =$('#bur_audit_remark').val();
		if(bur_audit_remark=null || bur_audit_remark==""){
			 top.$.alert('请输入审核备注','warn');
			 $('#bur_audit_remark').focus();
			 return false;
		}
		 return true;
	}

</script>
</html>